<template>
	<view class="changeInfo">
		<!-- <view class="title">编辑个人资料</view> -->
		<view class="nav-box">
			<!-- <view class="left">返回</view> -->
			
			<navigator 
			open-type="switchTab" 
			url="/pages/personal/personal" 
			class="iconfont iconfanhui icon-nav" 
			></navigator>
		</view>
		<view class="box">
			<view class="img-box">
				<image 
				class="img" 
				:src="scr"
				@click="chooseImg"
				></image>
				<view class="text">点击更换头像</view>
			</view>
		</view>
		<view class="info-box">
			<navigator open-type="redirect" url="/pages/modify/modify?title=userName" class="text-box">
				<view class="left">昵称</view>
				<view class="iconfont iconchangyongicon- icon-box"></view>
				<view class="right">{{user.userName}}</view>
			</navigator>
			<navigator open-type="redirect" url="/pages/modify/modify?title=douyinId" class="text-box">
				<view class="left">手机</view>
				<view class="iconfont iconchangyongicon- icon-box"></view>
				<view class="right">{{user.userId}}</view>
			</navigator>
			<navigator open-type="redirect" url="/pages/modify/modify?title=intrduction" class="text-box">
				<view class="left">真实姓名</view>
				<view class="iconfont iconchangyongicon- icon-box"></view>
				<view class="right">{{user.intrduction}}</view>
			</navigator>
			<picker :range="school" @change="bindSchoolChange">
				<view class="text-box">
					<view class="left">地区</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{user.school}}</view>	
				</view>
			</picker>
			<picker :range="sex" @change="bindSexChange">
				<view class="text-box">
					<view class="left">性别</view>
					<view class="iconfont iconchangyongicon- icon-box">	</view>
					<view class="right">{{user.sex}}</view>
				</view>
			</picker>
			<picker mode="date" :value="user.birthday"  @change="bindDateChange">
				<view class="text-box">
					<view class="left">生日</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{user.birthday}}</view>
				</view>
			</picker>
			
		</view>
	</view>
</template>
 
<script>
	export default {
		data() {
			return {
				src:'../../static/img/author.jpg',
				user:{
					userName:"闷油瓶",
					userId:"185****5412",
					intrduction:"张起灵",
					school:"",
					sex:"",
					birthday:'',
					city:''
				},
				school:['地球'],
				sex:['男','女']
			}
		},
		methods: {
			chooseImg(){
				uni.chooseImage({
					count:1,
					sourceType:['album'],
					sizeType:['original','compressed'],
					success: (res) => {
						this.src=res.tempFilePaths
					}
				})
			},
			bindSchoolChange(e){
				this.user.school=this.school[e.target.value]
				uni.setStorage({
					key:'school',
					data:this.school[e.target.value],
					
				})
			},
			bindSexChange(e){
				this.user.sex=this.sex[e.target.value]
				uni.setStorage({
					key:'sex',
					data:this.sex[e.target.value],
					
				})
			},
			bindDateChange(e){
				this.user.birthday=e.target.value
				uni.setStorage({
					key:'birthday',
					data:e.target.value,
					
				})
			}
			
			},
		onLoad() {
			uni.getStorage({
				key:'userName',
				success: (res) => {
					this.user.userName=res.data
				}
			}),
			uni.getStorage({
				key:'userId',
				success: (res) => {
					this.user.userId=res.data
				}
			}),
			uni.getStorage({
				key:'intrduction',
				success: (res) => {
					this.user.intrduction=res.data
				}
			}),
			uni.getStorage({
				key:'school',
				success: (res) => {
					this.user.school=res.data
				}
			}),
			uni.getStorage({
				key:'sex',
				success: (res) => {
					this.user.sex=res.data
				}
			}),
			uni.getStorage({
				key:'birthday',
				success: (res) => {
					this.user.birthday=res.data
				}
			}),
			uni.getStorage({
				key:'city',
				success: (res) => {
					this.user.city=res.data
				}
			})
		}
	}
</script>
 
<style>
.changeInfo{
	width: 100%;
	height: 100%;
	background: #FFFFFF;
}
.nav-box{
	height: 0px;
	position: relative;
	margin: 0 auto;
	padding-top: 0px;
}
.title{
	/* text-align: center; */
	color: #000000;
	font-size: 18px;
	/* position: absolute;
	top:15px; */
	display:flex;
	justify-content: center;
	
}
.icon-nav{
	position: absolute;
	top:30px;
	left: 10px;
	color: #000000;
}
.box{
	width: 100%;
	height: 150px;
	margin: 0 auto;
	border-top:10px solid #DCDCDC;
	border-bottom:10px solid #DCDCDC;
}
.img-box{
	text-align: center;
	
}
.img{
	margin-top: 20px;
	width: 70px;
	height: 70px;
	border-radius: 10%;
	background-image: url('../../static/fumou-center-template/header.jpg');
	background-size: cover;
}
.text{
	margin-top: 13px;
	color: #000000;
	font-size: 13px;
}
.info-box{
	padding:0 10px;
}
.text-box{
	width: 100%;
	height: 52px;
	line-height: 52px;
	
	
}
.left{
	float: left;
	font-size: 15px;
	color: #000000;
}
.right{
	float: right;
	font-size: 15px;
	margin-right: 7px;
	color: #000000;
}
.icon-box{
	float: right;
	font-size: 15px;
	color:  #000000;
	width: 10px;
}
</style>